package com.yhp.web;

import com.yhp.pojo.Orders;
import com.yhp.service.userservice.CenterOrderService;
import com.yhp.utils.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.io.File;

@Controller
public class BaseController {
    //用户头像保存地址   File.separator  文件夹之间的间隔符
    public static  final String IMAGE_HEADFACE_URL="F:"+ File.separator+"imooc"+File.separator+"uploadimg";

    //ctrl+shift+u 变量大小写转换
    public static final Integer COMMENT_PAGE_SIZE=10;
    //cookiename
    public static final String FOODIE_SHOPCART="shopcart";
    //支付回调接口地址
    //调用流程:微信支付成功->支付中心->天天吃货平台
    //上线环境下，注意这里要启动natapp并且在访问时要加项目名称
    public static final String PAY_RETURN_URL="http://uksh9f.natappfree.cc/orders/notifyOrderPaid";
    //支付中心地址
    public static final String  PAYMENTSERVERURL="http://payment.t.mukewang.com/foodie-payment/payment/createMerchantOrder";


    @Autowired
    protected CenterOrderService centerOrderService;
    //验证用户与订单是否有关联，避免用户非法调用
    public JSONResult checkUserOrder(String userId, String orderId){
        Orders orders = centerOrderService.queryMyOneOrder(userId, orderId);
        if(orders==null){
            return JSONResult.errorMsg("订单不存在");
        }
        return JSONResult.ok(orders);
    }


}
